package com.imut.lagain.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import jakarta.persistence.Column;
import jakarta.persistence.PreUpdate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 焦虑安抚提醒实体类
 */
@TableName("anxiety_reminder")
public class AnxietyReminder {
    private static final Logger log = LoggerFactory.getLogger(AnxietyReminder.class);


    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("user_id")
    private Long userId;

    @TableField("reminder_type")
    private String reminderType; // breathing, sensory, thought_check, emergency

    @TableField("title")
    private String title;

    @TableField("message")
    private String message;

    @TableField("frequency")
    private String frequency; // daily, weekly, custom

    @TableField("time_of_day")
    private LocalTime timeOfDay;

    @TableField("days_of_week")
    private String daysOfWeek; // 1,2,3,4,5,6,7 (周一到周日)

    @TableField("is_enabled")
    private Boolean isEnabled = true;

    @TableField("trigger_conditions")
    private String triggerConditions; // 触发条件(JSON格式)

    @TableField("anxiety_threshold")
    private Integer anxietyThreshold; // 焦虑阈值

    @TableField("last_triggered")
    private LocalDateTime lastTriggered;

    @TableField("next_trigger")
    private LocalDateTime nextTrigger;

    @TableField("trigger_count")
    private Integer triggerCount = 0;

    @TableField("response_count")
    private Integer responseCount = 0;

    @Column(name = "effectiveness_rating")
    private Double effectivenessRating; // 平均效果评分

    @Column(name = "priority", length = 10)
    private String priority; // low, medium, high, urgent

    @Column(name = "notification_method", length = 50)
    private String notificationMethod; // push, wechat, email

    @Column(name = "custom_sound", length = 100)
    private String customSound; // 自定义提醒音

    @Column(name = "vibration_pattern", length = 50)
    private String vibrationPattern; // 震动模式

    @Column(name = "snooze_duration")
    private Integer snoozeDuration; // 延迟时长(分钟)

    @Column(name = "max_snooze_count")
    private Integer maxSnoozeCount; // 最大延迟次数

    @Column(name = "auto_disable_after")
    private Integer autoDisableAfter; // 自动禁用天数

    @Column(name = "notes", length = 500)
    private String notes;

    @Column(name = "created_at")
    private LocalDateTime createdAt;

    @Column(name = "updated_at")
    private LocalDateTime updatedAt;

    @Column(name = "is_deleted")
    private Boolean isDeleted = false;
    public AnxietyReminder() {
        this.createdAt = LocalDateTime.now();
        this.updatedAt = LocalDateTime.now();
        this.priority = "medium";
        this.notificationMethod = "push";
        this.snoozeDuration = 10;
        this.maxSnoozeCount = 3;
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getReminderType() {
        return reminderType;
    }

    public void setReminderType(String reminderType) {
        this.reminderType = reminderType;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getFrequency() {
        return frequency;
    }

    public void setFrequency(String frequency) {
        this.frequency = frequency;
    }

    public LocalTime getTimeOfDay() {
        return timeOfDay;
    }

    public void setTimeOfDay(LocalTime timeOfDay) {
        this.timeOfDay = timeOfDay;
    }

    public String getDaysOfWeek() {
        return daysOfWeek;
    }

    public void setDaysOfWeek(String daysOfWeek) {
        this.daysOfWeek = daysOfWeek;
    }

    public Boolean getIsEnabled() {
        return isEnabled;
    }

    public void setIsEnabled(Boolean isEnabled) {
        this.isEnabled = isEnabled;
    }

    public String getTriggerConditions() {
        return triggerConditions;
    }

    public void setTriggerConditions(String triggerConditions) {
        this.triggerConditions = triggerConditions;
    }

    public Integer getAnxietyThreshold() {
        return anxietyThreshold;
    }

    public void setAnxietyThreshold(Integer anxietyThreshold) {
        this.anxietyThreshold = anxietyThreshold;
    }

    public LocalDateTime getLastTriggered() {
        return lastTriggered;
    }

    public void setLastTriggered(LocalDateTime lastTriggered) {
        this.lastTriggered = lastTriggered;
    }

    public LocalDateTime getNextTrigger() {
        return nextTrigger;
    }

    public void setNextTrigger(LocalDateTime nextTrigger) {
        this.nextTrigger = nextTrigger;
    }

    public Integer getTriggerCount() {
        return triggerCount;
    }

    public void setTriggerCount(Integer triggerCount) {
        this.triggerCount = triggerCount;
    }

    public Integer getResponseCount() {
        return responseCount;
    }

    public void setResponseCount(Integer responseCount) {
        this.responseCount = responseCount;
    }

    public Double getEffectivenessRating() {
        return effectivenessRating;
    }

    public void setEffectivenessRating(Double effectivenessRating) {
        this.effectivenessRating = effectivenessRating;
    }

    public String getPriority() {
        return priority;
    }

    public void setPriority(String priority) {
        this.priority = priority;
    }

    public String getNotificationMethod() {
        return notificationMethod;
    }

    public void setNotificationMethod(String notificationMethod) {
        this.notificationMethod = notificationMethod;
    }

    public String getCustomSound() {
        return customSound;
    }

    public void setCustomSound(String customSound) {
        this.customSound = customSound;
    }

    public String getVibrationPattern() {
        return vibrationPattern;
    }

    public void setVibrationPattern(String vibrationPattern) {
        this.vibrationPattern = vibrationPattern;
    }

    public Integer getSnoozeDuration() {
        return snoozeDuration;
    }

    public void setSnoozeDuration(Integer snoozeDuration) {
        this.snoozeDuration = snoozeDuration;
    }

    public Integer getMaxSnoozeCount() {
        return maxSnoozeCount;
    }

    public void setMaxSnoozeCount(Integer maxSnoozeCount) {
        this.maxSnoozeCount = maxSnoozeCount;
    }

    public Integer getAutoDisableAfter() {
        return autoDisableAfter;
    }

    public void setAutoDisableAfter(Integer autoDisableAfter) {
        this.autoDisableAfter = autoDisableAfter;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Boolean getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    @PreUpdate
    public void preUpdate() {
        this.updatedAt = LocalDateTime.now();
    }
}
